-- 三豌豆射手类
local Plant = require("app.mode.Plant")
local PeaShooter = require("app.mode.PeaShooter")

local ThreeShooter = {}
setmetatable(ThreeShooter, PeaShooter)
ThreeShooter.__index = ThreeShooter

-- 重写功能函数
function ThreeShooter:doFunc()
    local _, track = self:getLogicPosition()
    
    local z_count = Plant:getZCount(track)
    if track > 1 then
        z_count = z_count + Plant:getZCount(track - 1)
    end
    if track < 5 then
        z_count = z_count + Plant:getZCount(track + 1)
    end
    
    if self._scene and z_count > 0 then
        local x, y = self:getPosition()
        
        -- 发射三颗豌豆
        self:newWeapon("pea", x + 20, y + 24)
        if track > 1 then
            self:newWeapon("pea", x + 20, y - 76)
        end
        if track < 5 then
            self:newWeapon("pea", x + 20, y + 124)
        end
    end
end

return ThreeShooter
